<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2011 Alex Paréj.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ui:composition template="/WEB-INF/facelets/layouts/main.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui" 
                xmlns:md="http://java.sun.com/jsf/composite/md"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions">
    <ui:param name="title" value="#{msg.lomtar}"/>
    <ui:define name="body"> 
        <h:form id="dokumentumokForm">
            <p:dataTable id="dokTable"
                         value="#{lomtarController.dokumentumok}"
                         var="dok"
                         selectionMode="multiple"
                         selection="#{lomtarController.valasztottDokumentumok}"
                         sortBy="#{dok.nev}"
                         rowKey="#{dok.id}"
                         emptyMessage="#{msg.nincsAdat}"
                         rows="#{msg.datatableRows}" 
                         paginator="true"
                         paginatorPosition="bottom"
                         paginatorTemplate="#{msg.datatablePaginatorTemplate}"  
                         rowsPerPageTemplate="#{msg.datatableRowsPerPageTemplate}"
                         filteredValue="#{lomtarController.filteredDokumentumok}">
                <p:ajax event="rowSelect" update="funkcioGombok"/>
                <p:ajax event="rowUnselect" update="funkcioGombok"/>
                <f:facet name="header">
                    #{msg.lomtar}
                </f:facet>
                <p:column headerText="#{msg.nev}" sortBy="#{dok.nev}"
                          filterBy="#{dok.nev}">
                    #{dok.nev}
                </p:column>
                <p:column headerText="#{msg.tipus}" sortBy="#{dok.kiterjesztes}"
                          filterBy="#{dok.kiterjesztes}" style="width:120px">
                    #{dok.kiterjesztes}
                </p:column>
                <p:column headerText="#{msg.meret}" sortBy="#{dok.meret}" style="width:130px">
                    #{utilController.getMeret(dok)}
                </p:column>
                <p:column headerText="#{msg.dateCreated}" sortBy="#{dok.letrehozva}" style="width:115px">
                    <md:outputDate value="#{dok.letrehozva}"/>
                </p:column>
                <p:column headerText="#{msg.torolve}" sortBy="#{dok.torolve}" style="width:115px">
                    <md:outputDate value="#{dok.torolve}"/>
                </p:column>
                <f:facet name="footer">
                    <div style="float:left;padding: 0.4em">
                        #{fn:length(lomtarController.dokumentumok)} #{msg.db}
                    </div>
                    <div style="text-align: right">
                        <p:outputPanel id="funkcioGombok">
                            <p:commandButton icon="ui-icon-refresh" actionListener="#{lomtarController.visszaallit()}"
                                             disabled="#{lomtarController.nincsDokumentumValasztva}" title="#{msg.visszaallit}"
                                             update="@form :menu"/>
                            <p:commandButton icon="ui-icon-trash" title="#{msg.torol}"
                                             disabled="#{lomtarController.nincsDokumentumValasztva}"
                                             update=":dokTorleseConfirmDlg:dokumentumTorleseMegerositoDlg :menu"
                                             oncomplete="dokumentumTorleseMegerositoDlg.show();"/>
                        </p:outputPanel>
                    </div>
                </f:facet>
            </p:dataTable>
        </h:form>
        <md:deleteConfirmDlg id="dokTorleseConfirmDlg"
                             widgetVar="dokumentumTorleseMegerositoDlg" 
                             header="#{msg.dokumentumTorlese}" 
                             message="#{msg.biztosTorliAKijeloltDokumentumokat} (#{fn:length(lomtarController.valasztottDokumentumok)})"
                             update=":dokumentumokForm"
                             deleteAction="#{lomtarController.torolListener()}"/>
    </ui:define>
</ui:composition>


